<?php

/**
 * Kao class
 * 
 * Kao: PHP Web Framework <http://kao.byhuy.com/>.
 * Copyright 2008, Huy Nguyen <http://www.byhuy.com/>.
 * 
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 * 
 */


class Kao_Loader
{
    
    /**
     * Singleton instance
     */
    protected static $_instance = null;
      
    /**
     * Application path
     */
    protected $_appPath = '';
       
    
    private function __contruct()
    {
        
    }
    
    
    /**
     * Get singleton object
     */
    public static function getInstance()
    {
        if (null == self::$_instance)
        {
            self::$_instance = new self();
        }
        return self::$_instance;
    }
    
    
    protected function _loadFile()
    {
        
    }
    
    protected function _getPath($relativePath)
    {
        
    }
    
    
    /**
     * Sets application path
     * 
     * @param string $path
     * @return Kao_Loader
     */
    public function setAppPath($path)
    {
        $this->_appPath = $path;
        return $this;
    }
    
    /**
     * Load controller object
     * 
     * @param string $controllerName - Controller's name
     */
    public function loadController($controllerName)
    {
        
    }
    
    /**
     * Load config file
     * 
     * @param string $name - Config file name.
     * @param string $varname - Config variable name.
     */
    public function loadConfig($name, $varname = 'config')
    {
        $filepath = $this->_appPath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . $name . '.php';
        return ${$varname};
    }
    
    /**
     * Load component
     * 
     * @param string $type - Component type. One of Kao::COMP_*
     * @param string $name - Component name.
     * @param array $args - Arguments
     */
    public function loadComponent($type, $name, $args = array())
    {
        
    }
}
